PreviousValue (fld)

Basic syntax

PreviousValue and Previous (fld) are equivalent functions. However, you can use PreviousValue only with Basic syntax and Previous only with Crystal syntax

Argument

fld is the name of a database field.

Returns

Value of specified field; type depends on type of that field.

Action

PreviousValue returns the value of the previous record of the specified field.

Typical use

You can use previous to identify the last record in a previous range or the last record occurring before a new range begins, or to test for duplicate values.

Examples

The following examples are applicable to Basic syntax:

If PreviousValue ({Orders Detail.Quantity}) <> 0 Then

    formula = {Orders Detail.Quantity} / 2

Else

    formula = {Orders Detail.Quantity}

End If

Tests the previous value in the {Orders Detail.Quantity} field to see if it is a zero value. If it is not, it divides the current value by two. If it is a zero value, it returns the current value itself.

If PreviousValue ({Orders.Order ID}) Mod 10 = 0 Then

    formula = "Beginning of new block"

Else

    formula = "Same block"

End If

Divides orders into blocks of 10. If the previous Order ID is a multiple of 10, it flags the current value as "Beginning of new block". Otherwise, it prints "Same block".

If PreviousValue ({Customer.Customer ID}) = {Customer.Customer ID} Then

    formula = "Customer Repeated"

Else

    formula = "Customer Changed"

End If

This flags repeated values in the {Customer.Customer ID} field.

Note:    Using this function in a formula forces the formula to be evaluated at print time. For more information on evaluation time considerations, see Evaluation Time functions.



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com